package listbyorder.access101_200.test125;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/8 13:38
 */
public class Solution1 {

    // 验证回文串
    public boolean isPalindrome(String s) {
        if (s == null || s.equals("")) return true;
        char[] chars = s.toCharArray();
        StringBuilder lr = new StringBuilder();
        StringBuilder rl = new StringBuilder();
        int len = chars.length;
        char temp1;
        char temp2;
        for (int i = 0; i < len; i++) {
            temp1 = chars[i];
            temp2 = chars[len - 1 - i];
            if ((temp1 >= '0' && temp1 <= '9') || (temp1 >= 'a' && temp1 <= 'z') || (temp1 >= 'A' && temp1 <= 'Z')) {
                lr.append(temp1);
            }
            if ((temp2 >= '0' && temp2 <= '9') || (temp2 >= 'a' && temp2 <= 'z') || (temp2 >= 'A' && temp2 <= 'Z')) {
                rl.append(temp2);
            }
        }
        return lr.toString().toLowerCase().equals(rl.toString().toLowerCase());
    }
}
